package Demo;

import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

public class test {
    public static void main(String[] args) {

    }
    @Before
    public void init(){
        System.out.println("run...");
    }
    @After
    public void close(){
        System.out.println("close...");
    }
    @Test
    public void show(){
        String str1 = "wo ai java wo ai java ba";
        String str2 = "wo ai java ba";
        char[] c1 =str1.toCharArray();
        char[] c2 = str2.toCharArray();
        int i = 0;
        int j = 0;
        while (j<c2.length&&i<c1.length){
            if(c1[i]==c2[j]){
                i++;
                j++;
            }else {
                i=i-j+1;
                j=0;
            }
        }
        System.out.println(i-j);
            Assert.assertEquals(11,i-j);

    }
}